﻿<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output method="text" />
	<xsl:template match="/">
		using System;
		using System.Data;
		using System.Data.SqlClient;
		using System.Data.SqlTypes;
		using System.Xml;
		using System.Reflection;
		using System.Configuration;
		using ESpace.DALibrary.SqlServer;

		namespace <xsl:value-of select="Schema/@NameSpace" />
		{
		<xsl:if test="Schema/@IsInternal='True'">internal</xsl:if><xsl:if test="Schema/@IsInternal='False'">public</xsl:if> class <xsl:value-of select="Schema/@StoreProcedureName" /> : DataAccessBase
		{
		public <xsl:value-of select="Schema/@StoreProcedureName" />()
		{
		base.EncryptMethod = ESpace.DALibrary.Alogrim.SymmProvEnum.<xsl:value-of select="Schema/@EncryptMethod" />;
		base.Key = "<xsl:value-of select="Schema/@Key" />";
		base.IV = "<xsl:value-of select="Schema/@IV" />";
		ConnectionString = ConfigurationManager.AppSettings["<xsl:value-of select="Schema/@DBName" />"];
		base.InitCommand("<xsl:value-of select="concat('[',Schema/@Owner,'].[',Schema/@StoreProcedureName,']')" />");
		ConfigParameter();
		}
		<xsl:for-each select="Schema/Columns">
			private SqlParameter param<xsl:value-of select="COLUMN_NAME" />;
			public <xsl:value-of select="concat(LANGUAGE_TYPE,' ',COLUMN_NAME)" />
			{
			get
			{
			return (<xsl:value-of select="LANGUAGE_TYPE" />)param<xsl:value-of select="COLUMN_NAME" />.Value;
			}
			set
			{
			param<xsl:value-of select="COLUMN_NAME" />.Value = value;
			}
			}
		</xsl:for-each>
		public void ConfigParameter()
		{<xsl:for-each select="Schema/Columns">
			//--------------------------------------------------------
			param<xsl:value-of select="COLUMN_NAME" /> = new SqlParameter();
			param<xsl:value-of select="COLUMN_NAME" />.ParameterName = "@<xsl:value-of select="COLUMN_NAME" />";
			param<xsl:value-of select="COLUMN_NAME" />.SqlDbType = <xsl:value-of select="DB_TYPE" />;<xsl:if test="DATA_TYPE&gt;1 and DATA_TYPE&lt;8">
				param<xsl:value-of select="COLUMN_NAME" />.Precision = <xsl:value-of select="PRECISION" />;
			</xsl:if><xsl:if test="DATA_TYPE&lt;2 or DATA_TYPE&gt;7">
				param<xsl:value-of select="COLUMN_NAME" />.Size = <xsl:value-of select="LENGTH" />;
			</xsl:if><xsl:if test="SCALE">
				param<xsl:value-of select="COLUMN_NAME" />.Scale = <xsl:value-of select="SCALE" />;
			</xsl:if>
			param<xsl:value-of select="COLUMN_NAME" />.Direction = ParameterDirection.<xsl:choose>
				<xsl:when test="COLUMN_TYPE='1'">Input</xsl:when>
				<xsl:when test="COLUMN_TYPE='2'">InputOutput</xsl:when>
				<xsl:when test="COLUMN_TYPE='5'">ReturnValue</xsl:when>
			</xsl:choose>;
			param<xsl:value-of select="COLUMN_NAME" />.Value = DBNull.Value;
			base.sqlComm.Parameters.Add(this.param<xsl:value-of select="COLUMN_NAME" />);
		</xsl:for-each>
		}
		}
		}
	</xsl:template>
</xsl:stylesheet>